import math as m
import tkinter as tk

window=tk.Tk()
window.title("地理日影长度程序")
window.geometry("300x300")

t1=tk.Text(window,width=35,height=2,bg="pink")
t1.insert("end","please insert the day under me")
t1.pack()

e1=tk.Entry(window,width=35,bg="pink")
e1.pack()

t6=tk.Text(window,width=35,height=2,bg="pink")
t6.insert("end","please insert the time under me")
t6.pack()

e4=tk.Entry(window,width=35,bg="pink")
e4.pack()

t2=tk.Text(window,width=35,height=2,bg="pink")
t2.insert("end","please insert the minutes under me")
t2.pack()

e2=tk.Entry(window,width=35,bg="pink")
e2.pack()

t3=tk.Text(window,width=35,height=2,bg="pink")
t3.insert("end","please insert the seconds under me")
t3.pack()

e3=tk.Entry(window,width=35,bg="pink")
e3.pack()


t4=tk.Text(window,width=35,height=2,bg="pink")
t4.insert("end","当前太阳的高度角为：")
t4.pack()

t5=tk.Text(window,width=35,height=2,bg="pink")
t5.insert("end","当前太阳的方位角为：")
t5.pack()
global n, mmm, s,time1

def date_get():
    n=int(e1.get())
    print(n)
    s=int(e3.get())
    print(s)
    mmm=int(e2.get())
    print(mmm)
    time1=int(e4.get())


    alpha=0.006918-0.399912*m.cos((2*m.pi*(n-1))/365)+0.070257*m.sin((2*m.pi*(n-1))/365)-0.006758*m.cos(2*((2*m.pi*(n-1))/365))+0.000907*m.sin(2*((2*m.pi*(n-1))/365))-0.002697*m.cos(3*((2*m.pi*(n-1))/365))+0.00148*m.sin(3*((2*m.pi*(n-1))/365))  #用公式计算
    beta=alpha/(0.0174533)
    
    y=((m.pi)/180)*(39+(54/60)+(20/3600)) 

    x=mmm/60+s/3600   #把角度转化为100进制
    t2=time1-(14+(44/60))/60  #把角度转化为100进制
    t3=t2+x
    t=(((m.pi)/180)*15)*(t3-12)

    gamma=m.sin(y)*m.sin(alpha)+m.cos(y)*m.cos(alpha)*m.cos(t)  #代公式求值
    hhh=m.asin(gamma)  #同上
    h=hhh/(0.0174533)
    t4.insert("end",h)

    a1=(m.sin(alpha)-m.sin(hhh)*m.sin(y))/(m.cos(hhh)*m.cos(y))
    a2=m.acos(a1)
    a=a2/(0.0174533)
    t5.insert("end",a)







b1=tk.Button(window,width=35,text="press me to return the result",command=date_get,bg="pink")
b1.pack()

l1=tk.Label(window,width=300,height=300,bg="pink")

window.mainloop()